﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace MagicArena.framework.graphics._2d
{
    public class AssetManager<T>
    {
        #region Singleton Code
        public static AssetManager<T> Instance
        {
            get
            {
                if (_Instance == null) _Instance = new AssetManager<T>();
                return _Instance;
            }
        }
        private static AssetManager<T> _Instance;
        private AssetManager()
            : base()
        {

        }
        #endregion

        #region Private variables
        Dictionary<string, T> _AssetDictionary = new Dictionary<string, T>(10);
        #endregion

        #region 

        #endregion

        public void LoadContent(Game game)
        {
            
            T tex = game.Content.Load<T>("wizardSingle");
            _AssetDictionary.Add("wizard", tex);
            
        }
        public void UnloadContent(Game game)
        {
            game.Content.Unload();
        }

        #region Getters
        public T GetTex(string name)
        {
            T o;
            if (_AssetDictionary.TryGetValue(name, out o))
            {
                return o;
            }
            throw new ArgumentException("Cannot find Texture2d asset of name " + name);
            return default(T);
        }
        #endregion
    }
}
